package LeetcodeTest_thirty_seven;

//面试题 17.16. 按摩师
public class massage
{
    public static void main(String[] args)
    {
        int[] nums={2,1,4,5,3,1,1,3};
        System.out.println(solution.massage(nums));
    }
}
class solution
{
    public static int massage(int[] nums)
    {
        int n=nums.length;
        int[] dp=new int[n];
        if(n==0)
            return 0;
        if(n==1)
          return nums[0];
        if(n>=2)
        {
            dp[0]=nums[0];
            dp[1]=Math.max(nums[0],nums[1]);
            for(int i=2;i<n;i++)
            {
                dp[i]=Math.max(dp[i-1],dp[i-2]+nums[i]);
            }
        }
        return dp[n-1];
    }
}